<?php

namespace Admin\Controller;

class CompanyController extends AdminbaseController {

    function _initialize() {
        parent::_initialize();
        $this->currentModel = D("Company");
    }

    //首页
    public function index() {

        $requestMap = $this->convertRequestToMap();

        //分页
        $count = $this->currentModel->getListCount($requestMap);
        $page = $this->page($count, C("DEFAULT_PAGE_SIZE"));

        //获取合作商列表
        $list = $this->currentModel->queryForList($page, $requestMap);

        $this->assign("statusEnum", C("DEFAULT_YN"));
        $this->assign('list', $list);
        $this->assign("page", $page->show('Admin', $this->parameter));
        $this->display();

    }

    public function notifyCompany() {

        $id = $_REQUEST["id"];

        $this->assign("id", $id);
        $this->display();

    }

    public function notifyCompanyPost() {

        $id = $_REQUEST["id"];
        $company = D("Company")->queryById($id);

        $customer = D("Customer")->queryById($company["customer_id"]);

        $data["openid"] = $customer["openid"];
        $data["title"] = $_REQUEST["title"];
        $data["orderNumber"] = $_REQUEST["orderNumber"];
        $data["remark"] = $_REQUEST["remark"];
        $data["serviceName"] = $_REQUEST["serviceName"];
        $data["count"] = $_REQUEST["count"];
        $data["price"] = $_REQUEST["price"];

        wechatNotifyDoctor($data);

        $this->success("发送成功", U("company/index"));

    }

}